package com.jilefojing.beans.enums.forcomment;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;

/**
 * 
 * @author 作者 jgshun
 * @date 创建时间 2016年07月21日 15时40分56秒
 */
public enum StatusEnumForComment {
	/**
	 * (short) 1, "有效"
	 */
	VALID((short) 1, "有效"),
	/**
	 * (short) 2, "用户删除"
	 */
	DELETE_BY_USER((short) 2, "用户删除"),
	/**
	 * (short) 3, "系统删除"
	 */
	DELETE_BY_SYSTEM((short) 3, "系统删除");

	private short code;
	private String msg;

	private StatusEnumForComment(short code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public short getCode() {
		return code;
	}

	public void setCode(short code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	@Override
	public String toString() {
		if (this != null) {
			Map<String, Object> allMap = new HashMap<String, Object>();
			allMap.put("code", this.code);
			allMap.put("msg", this.msg);
			String result = JSONObject.toJSONString(allMap);
			result = result.replaceAll("\"", "'");
			return result;
		}
		return super.toString();
	}

	public static StatusEnumForComment getStatusEnumByCode(short code) {
		for (StatusEnumForComment _enum : StatusEnumForComment.values()) {
			if (_enum.getCode() == code) {
				return _enum;
			}
		}
		return null;
	}
}
